using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class GUI_Webpage_Login : System.Web.UI.Page
{
    UserInfo userInfo = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RoleBll roleBll = new RoleBll();
            roleBll.LoadRole(drpRole);
        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        UserBll userBll = new UserBll();
        userInfo = new UserInfo();

        userInfo.UserID = txtUserID.Text;
        userInfo.Password = txtPassword.Text;        
        userInfo.RoleID = Int32.Parse(drpRole.SelectedValue);

        if (Convert.ToInt32(userBll.CheckLogin(userInfo)) > 0)
        {
            Session["user"] = userInfo.UserID;
            Session["password"] = userInfo.Password;
            Session["role"] = userInfo.RoleID;
            if (userInfo.RoleID == 0)
            {
                Response.Redirect("Admin/UserManagement.aspx");
            }
            else
                if (userInfo.RoleID == 1)
                {
                    Response.Redirect("Manager/ManageBooking.aspx");
                }
        }
    }
}
